/* const express = require('express');
const app = express()
const cors = require('cors')


app.use(express.json())
app.use(express.urlencoded({extended:false}))
// 方案一 原生的
app.use((req,res,next)=>{
    res.setHeader("Access-Control-Allow-Origin", "*"); 
    res.setHeader('Access-Control-Allow-Methods','*')
  next();
})

//方案二 cors
app.use(cors())


app.get('/home',(req,res)=>{
    res.send({
        status:200,
        name:'home',
        msg:'express 接口编写',
        data:[req.query]
    })
})

app.post('/add',(req,res)=>{
    res.send({
        status:200,
        name:'home',
        msg:'express 接口编写',
        data:[req.body]
    })
})

app.delete('/delete',(req,res)=>{
    res.send({
        status:200,
        name:'home',
        msg:'express 接口编写',
        data:[req.query]
    })
})

app.put('/put',(req,res)=>{
    res.send({
        status:200,
        name:'home',
        msg:'express 接口编写',
        data:[req.body]
    })
})

app.listen(8080, () => {
    console.log("8080 running");
  }); */